﻿ 

using System;
using System.Buffers.Text;
using System.Text;

string[] extensions = new string[] { ".jpg", ".bmp", ".jpeg", ".png", ".tif", ".tiff" };
string imageroot = Environment.CurrentDirectory + "//image";
if (!Directory.Exists(imageroot)) Directory.CreateDirectory(imageroot);
DirectoryInfo directoryInfo = new DirectoryInfo(imageroot);
var files = directoryInfo.GetFiles("*.*");

DateTime dt1;
DateTime dt2;
foreach (var file in files)
{
       
    if (!extensions.Contains(file.Extension.ToLower())) continue;
      byte[] imagebyte = File.ReadAllBytes(file.FullName);
     string base64 = Convert.ToBase64String(imagebyte);
    dt1 = DateTime.Now;
    var s = WebAPIClient.WebAPIClient.DetectText(base64);
     
    dt2 = DateTime.Now;
    Console.WriteLine((dt2-dt1).TotalMilliseconds);
  
   Console.WriteLine(s);
}
    Console.ReadKey();
